const http = require("http");
http.createServer((request, response) => {
  let body = [];
  request.on('error', error => {
    console.log(error)
  }).on('data', chunk => {
    console.log(1, chunk)
    body.push(chunk)
  }).on('end', () => {
    body = Buffer.concat(body).toString()
    console.log('body:', decodeURIComponent(body))
    response.writeHead(200, {'Context-Type': 'text/html'})
  //     response.end(
  //   `<html maaa=a >
  //  <head>
  //     <style>
  //     </style>
  //   </head>
  //   <body>
  //     <div id="container">
  //      <div id="myid"></div>
  //      <div class="c1"></div>
  //     </div>
  //   </body>
  //   </html>`)
    response.end(
    `<html maaa=a >
   <head>
      <style>
      body #container{
        width: 500px;
        height: 300px;
        display: flex;
        background-color: rgb(255, 255, 255)
      }
      body #container #myid{
        width: 200px;
        height: 100px;
        background-color: rgb(255, 0, 0)
      }
      body #container .c1{
        flex:1;
        background-color: rgb(0, 255, 0)
      }
      </style>
    </head>
    <body>
      <div id="container">
       <div id="myid"></div>
       <div class="c1"></div>
      </div>
    </body>
    </html>`)
  })
}).listen(8080);

console.log('Server started')

